package cn.ekuma.impexp;

import com.openbravo.data.loader.TableDefinition;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.swing.tree.TreeNode;

public class TableDefinitionTreeNode implements TreeNode {

    String group;
    List<TableDefinition> tables;
    List<TableDefinitionTreeNode> nodes;
    TableDefinitionTreeNode parent;

    public TableDefinitionTreeNode(String group, TableDefinitionTreeNode parent) {
        this.group = group;
        this.parent = parent;
        nodes = new ArrayList<TableDefinitionTreeNode>();
        tables = new ArrayList<TableDefinition>();
    }

    public TableDefinitionTreeNode() {
        this("root",null);
    }

    public TreeNode getChildAt(int childIndex) {
        return nodes.get(childIndex);
    }

    public int getChildCount() {
        return nodes.size();
    }

    public TreeNode getParent() {
        return parent;
    }

    public int getIndex(TreeNode node) {
        return nodes.indexOf(node);
    }

    public boolean getAllowsChildren() {
        return true;
    }

    public boolean isLeaf() {
        return false;
    }

    public Enumeration children() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getGroup() {
        return group;
    }

    public List<TableDefinitionTreeNode> getNodes() {
        return nodes;
    }

    public List<TableDefinition> getTables() {
        return tables;
    }
}
